package cn.org.atool.fluent.mybatis.metadata;

import cn.org.atool.fluent.mybatis.metadata.feature.DbFeature;

import static cn.org.atool.fluent.mybatis.metadata.feature.EscapeExpress.*;
import static cn.org.atool.fluent.mybatis.metadata.feature.PagedFormat.*;

/**
 * 不同数据库的特性描述
 *
 * @author wudarui
 */
@SuppressWarnings("unused")
public interface DbFeatures {
    DbFeature DF_MYSQL = new DbFeature("mysql", "MySql数据库")
        .setDriver("com.mysql.cj.jdbc.Driver")
        .setUrlPrefix("jdbc:mysql:")
        .setEscape(BACK_ESCAPE)
        .setPaged(MYSQL_LIMIT)
        .setSeq("SELECT LAST_INSERT_ID() AS ID");

    DbFeature DF_MARIADB = DF_MYSQL.copy().setName("mariadb").setDesc("MariaDB数据库");

    DbFeature DF_H2 = new DbFeature("h2", "H2数据库")
        .setDriver("org.h2.Driver")
        .setUrlPrefix("jdbc:h2:")
        .setEscape(BACK_ESCAPE)
        .setPaged(MYSQL_LIMIT)
        .setMemory(true);

    DbFeature DF_SQLITE = new DbFeature("sqlite", "SQLite数据库")
        .setDriver("org.sqlite.JDBC")
        .setUrlPrefix("jdbc:sqlite:")
        .setFixSchema("")
        .setEscape(D_QUOTATION_ESCAPE)
        .setPaged(PG_LIMIT);

    DbFeature DF_HSQLDB = new DbFeature("hsqldb", "HSql数据库")
        .setDriver("org.hsqldb.jdbcDriver")
        .setUrlPrefix("jdbc:hsqldb:")
        .setFixSchema("PUBLIC.PUBLIC")
        .setPaged(HSQLDB_LIMIT)
        .setMemory(true);

    DbFeature DF_POSTGRE_SQL = new DbFeature("postgresql", "PostgreSql数据库")
        .setDriver("org.postgresql.Driver")
        .setUrlPrefix("jdbc:postgresql:")
        .setEscape(D_QUOTATION_ESCAPE)
        .setPaged(PG_LIMIT);

    DbFeature DF_DERBY = new DbFeature("derby", "DERBY数据库")
        .setDriver("org.apache.derby.jdbc.EmbeddedDriver")
        .setUrlPrefix("jdbc:derby:")
        .setEscape(D_QUOTATION_ESCAPE)
        .setPaged(DERBY_LIMIT)
        .setMemory(true);

    DbFeature DF_CLICK_HOUSE = new DbFeature("clickhouse", "clickhouse数据库")
        .setDriver("ru.yandex.clickhouse.ClickHouseDriver")
        .setUrlPrefix("jdbc:clickhouse:")
        .setEscape(NONE_ESCAPE)
        .setPaged(MYSQL_LIMIT);

    DbFeature DF_DB2 = new DbFeature("db2", "DB2数据库")
        .setEscape(NONE_ESCAPE)
        .setPaged(DB2_LIMIT);

    DbFeature DF_INFORMIX = new DbFeature("informix", "informix数据库")
        .setEscape(NONE_ESCAPE)
        .setPaged(INFORMIX_LIMIT);

    DbFeature DF_ORACLE = new DbFeature("oracle", "ORACLE数据库")
        .setDriver("oracle.jdbc.OracleDriver")
        .setUrlPrefix("jdbc:oracle:")
        .setPaged(ORACLE_LIMIT)
        .setSeq("select SEQ_USER_ID.nextval as id from dual")
        .setBefore(true);

    DbFeature DF_ORACLE12 = new DbFeature("oracle", "ORACLE12数据库")
        .setDriver("oracle.jdbc.OracleDriver")
        .setUrlPrefix("jdbc:oracle:")
        .setPaged(ORACLE12_LIMIT)
        .setSeq("select SEQ_USER_ID.nextval as id from dual")
        .setBefore(true);

    DbFeature DF_SQL_SERVER2005 = new DbFeature("sqlserver2005", "SqlServer2005数据库")
        .setDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver")
        .setUrlPrefix("jdbc:sqlserver:")
        .setEscape(SQUARE_BRACKETS_ESCAPE)
        .setPaged(SQLSERVER2005_LIMIT);

    DbFeature DF_SQL_SERVER2012 = new DbFeature("sqlserver2012", "SqlServer2012数据库")
        .setDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver")
        .setUrlPrefix("jdbc:sqlserver:")
        .setEscape(SQUARE_BRACKETS_ESCAPE)
        .setPaged(SQLSERVER2012_LIMIT);

    DbFeature DF_FIREBIRD = new DbFeature("firebird", "Firebird数据库")
        .setPaged(FIREBIRD_LIMIT);
}